package tenet.protocol.network.arp;

import tenet.protocol.IProtocol;
import tenet.protocol.interrupt.InterruptObject;
import tenet.protocol.interrupt.InterruptParam;
import tenet.protocol.network.INetworkLayer;
import tenet.util.pattern.serviceclient.IClient;
import tenet.util.pattern.serviceclient.IRegistryableService;
import tenet.util.pattern.serviceclient.IService;


//The MAC conflict should throw the 0x80000500 to the upper layer.
public class ARP extends InterruptObject implements INetworkLayer,
		IRegistryableService<Integer> {

	

	public ARP() {
		//The initialization
		
	}
	

	
	public void send(int HTYPE, byte[] hardwareAddr, int PTYPE, byte[] protocolAddr) {
		//The basic function that you can send a arp package to the others.
		//SEther's HTYPE is 1, IPv4's PTYPE is 0x0800 as default
		//Some different PTYPE will appear in the verification
	}


	public byte[] getHardwareAddress(int PTYPE, byte[] protocolAddr) {
		//The mapping you have maintained will be used by some other protocol.
		//The higher layer will use it to get the mac.

	}

	@Override
	protected void interruptHandle(int signal, InterruptParam param) {
		// This is the most important function in ARP.
		// Ths signals may be caused by the IDataLinkLayer and yourself.
		// IDataLinkLayer.INT_FRAME_RECEIVE & IDataLinkLayer.INT_FRAME_TRANSMIT are the important signals. 
		
	}

	@Override
	public void dump() {
		// TODO This is used for the debugging. You may use it to export something iteratively.	

	}

	@Override
	public String getIdentify() {
		return null;
	}

	@Override
	public String getName() {
		return null;		
	}

	@Override
	public void registryClient(IClient<Integer> client) {
		//A higher layer client may transfer it.

	}

	@Override
	public void unregistryClient(IClient<Integer> client) {
		
	}

	@Override
	public void unregistryClient(Integer id) {

	}

	@Override
	public void attachTo(IService service) {
		// TODO You will attachTo a lower layer in the Protocol Stack. 
		
	}

	@Override
	public void detachFrom(IService service) {
		
	}

	@Override
	public Integer getUniqueID() {
		// TODO return the Protocol ID.
		
	}

	@Override
	public void setUniqueID(Integer id) {
		// TODO Set the Protocol ID.		
	}


}

class ArpFrame {
	// the ARP frame data struct. 

}